package project.tool4nat.server;

import project.tool4nat.common.Config;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.*;
import java.util.Properties;

public class ConfigTest {
    public static void main(String[] args) {
        System.out.println(Config.SERVER_HOST);
        System.out.println(Config.SERVER_PORT);
        String confPath = System.getProperty("user.dir");
        System.out.println(confPath);
        System.out.println(System.getProperty("config.name"));
        try {
            WatchService watchService = FileSystems.getDefault().newWatchService();
            Path path = FileSystems.getDefault().getPath("c:/users/hasee/desktop");
            path.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);

            while (true) {
                WatchKey key = watchService.take();
                for (WatchEvent event : key.pollEvents()){
                    System.out.println(event);
                }

            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        /*try (InputStream in = new FileInputStream(new File(System.getProperty("config")))) {
            Properties properties = new Properties();
            properties.load(in);
            String host = properties.getProperty("server.host", "default host");
            String port = properties.getProperty("server.port", "default port");
            System.out.println(host);
            System.out.println(port);
        } catch (IOException e) {
            e.printStackTrace();
        }*/
    }
}
